﻿/**
*   A Very basic Model class
*/
function LabModel(property1){
    this.property1=property1 || "Some initial property";
}

/**
*   A Very basic DAO class 
*/
function LabDAO(oModel){
    var _oModel=oModel;

    //  DAO Get method
    this.get=function(){alert("DAO LOAD");return _oModel}
    
    //  DAO Save method
    this.save=function(){alert("DAO SAVE");}
    
    //  DAO Delete method
    this.destroy=function(){alert("DAO DELETE");}
}

/**
*   A Very basic JSON DAO class 
*/
function JSONDAO(oModel){
    var _oModel=oModel || null;
    
    //  DAO Get method
    this.get=function(){alert("JSON LOAD");return _oModel}
    
    //  DAO Save method
    this.save=function(){alert("JSON SAVE");}
    
    //  DAO Delete method
    this.destroy=function(){alert("JSON DELETE");}
}

/**
*   A Very basic service class
*/
function LabService(oLabDao){
    var _oLabDao = oLabDao || null;
    
    //  Service Get method
    this.get=function(){
        alert("SERVICE GET");
        return _oLabDao.get();
    }
    
    //  Getter for DAO instance
    this.getDao=function(){
        return _oLabDao;
    }
    
    //  Setter for DAO instance
    this.setDao=function(oLabDao){
        _oLabDao=oLabDao;
    }
}

/**
*   A Very basic application class
*/
function LabApplication(){
    var _oService=null;                 //  Reference to the service instance
    
    //  Invoked by container when context support is provided
    this.onContextSupport=function(oContainerContext){  
        var _oModel=_oService.get();
        //alert("Property of model is "+_oModel.property1);
        var _oSpan=$('span#iOutput')[0];
        $(_oSpan).html(_oModel.property1);
    }
    
    //  Setter for service instance
    this.setService=function(oService){
        _oService=oService;
    }
}
